package top.wardyan.wdev.dbassist.action.base;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import top.wardyan.action.base.AbstractShell;

public class BaseDialog extends Dialog {

	protected Object result;
	protected Shell shell;

	/**
	public BaseDialog(Shell parent, int style) {
		super(parent, style);
		
	}
	
	public BaseDialog(Shell parent) {
		this(parent, SWT.CLOSE);
	}
	**/
	public BaseDialog(Shell parent, AbstractShell<?> shell, int style) {
		super(parent, style);
		this.shell = shell;
	}
	
	public BaseDialog(Shell parent, AbstractShell<?> shell) {
		this(parent, shell, SWT.CLOSE);
	}
	
	
	
	
	

	public Object open() {
		createContents();
		shell.open();
		shell.layout();
		Display display = getParent().getDisplay();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		return result;
	}

	private void createContents() {
		/**
		if(shell == null) {
			shell = new Shell(getParent(), getStyle());
			shell.setSize(600, 480);
			shell.setText(getTitle());
		}
		**/
	}

	

}
